package com.epam.run;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.epam.resources.Resources;
import com.epam.tasks.FirstSentenceWordOccurence;
import com.epam.text_elements.Sentence;
import com.epam.text_elements.Text;

public class Runner {

	public static void main(String[] args) {
		try {
			List<String> lines = Files.readAllLines(Paths.get(
					System.getProperty("user.dir") 
					+ Resources.getString("srcTextFile")), 
					StandardCharsets.UTF_8);
			Text text = new Text(lines);
			PropertyConfigurator.configure(System.getProperty("user.dir") 
					+ Resources.getString("loggingProp")); 
			Logger logger = Logger.getLogger(Runner.class.getName());
			logger.info(text.getSentencesSortedByNumWords());
			Sentence firstSentence = text.get(0).getFirstSentence();
			logger.info(FirstSentenceWordOccurence
					.findOccurence(text, firstSentence));
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
}
